var Building_Max_Percentage = 99 ;

var Building_Prov                = "";
var Building_Kingdom             = 0;
var Building_Island              = 0; 
var Building_Race                = 0;
var Building_Personality         = 0;
var Building_Stance              = 0;

var Building_Available_Workers   = 0;
var Building_Total_Money         = 0;

var Building_Building_Cost       = 0;
var Building_Razing_Cost         = 0;
var Building_Total_Jobs          = 0;
var Building_Total_NW            = 0;
var Building_Total_Cost          = 0;

var Building_Available_Barren    = 0;
var Building_Available_Homes     = 0;
var Building_Available_Farms     = 0;
var Building_Available_Mills     = 0;
var Building_Available_Banks     = 0;
var Building_Available_TG        = 0;
var Building_Available_Armouries = 0;
var Building_Available_Barracks  = 0;
var Building_Available_Forts     = 0;
var Building_Available_GS        = 0;
var Building_Available_Hospitals = 0;
var Building_Available_Guilds    = 0;
var Building_Available_Towers    = 0;
var Building_Available_TD        = 0;
var Building_Available_WT        = 0;
var Building_Available_Libraries = 0;
var Building_Available_Schools   = 0;
var Building_Available_Stables   = 0;
var Building_Available_Dungeons  = 0;
var Building_Available_Total     = 0;


var Building_Percentage_Barren    = 0;
var Building_Percentage_Homes     = 0;
var Building_Percentage_Farms     = 0;
var Building_Percentage_Mills     = 0;
var Building_Percentage_Banks     = 0;
var Building_Percentage_TG        = 0;
var Building_Percentage_Armouries = 0;
var Building_Percentage_Barracks  = 0;
var Building_Percentage_Forts     = 0;
var Building_Percentage_GS        = 0;
var Building_Percentage_Hospitals = 0;
var Building_Percentage_Guilds    = 0;
var Building_Percentage_Towers    = 0;
var Building_Percentage_TD        = 0;
var Building_Percentage_WT        = 0;
var Building_Percentage_Libraries = 0;
var Building_Percentage_Schools   = 0;
var Building_Percentage_Stables   = 0;
var Building_Percentage_Dungeons  = 0;
var Building_Percentage_Total     = 0;


var Building_Progress_Barren    = 0;
var Building_Progress_Homes     = 0;
var Building_Progress_Farms     = 0;
var Building_Progress_Mills     = 0;
var Building_Progress_Banks     = 0;
var Building_Progress_TG        = 0;
var Building_Progress_Armouries = 0;
var Building_Progress_Barracks  = 0;
var Building_Progress_Forts     = 0;
var Building_Progress_GS        = 0;
var Building_Progress_Hospitals = 0;
var Building_Progress_Guilds    = 0;
var Building_Progress_Towers    = 0;
var Building_Progress_TD        = 0;
var Building_Progress_WT        = 0;
var Building_Progress_Libraries = 0;
var Building_Progress_Schools   = 0;
var Building_Progress_Stables   = 0;
var Building_Progress_Dungeons  = 0;
var Building_Progress_Total     = 0;


var Building_Goal_Barren    = 0;
var Building_Goal_Homes     = 0;
var Building_Goal_Farms     = 0;
var Building_Goal_Mills     = 0;
var Building_Goal_Banks     = 0;
var Building_Goal_TG        = 0;
var Building_Goal_Armouries = 0;
var Building_Goal_Barracks  = 0;
var Building_Goal_Forts     = 0;
var Building_Goal_GS        = 0;
var Building_Goal_Hospitals = 0;
var Building_Goal_Guilds    = 0;
var Building_Goal_Towers    = 0;
var Building_Goal_TD        = 0;
var Building_Goal_WT        = 0;
var Building_Goal_Libraries = 0;
var Building_Goal_Schools   = 0;
var Building_Goal_Stables   = 0;
var Building_Goal_Dungeons  = 0;
var Building_Goal_Total     = 0;


var Build_This_Barren    = 0;
var Build_This_Homes     = 0;
var Build_This_Farms     = 0;
var Build_This_Mills     = 0;
var Build_This_Banks     = 0;
var Build_This_TG        = 0;
var Build_This_Armouries = 0;
var Build_This_Barracks  = 0;
var Build_This_Forts     = 0;
var Build_This_GS        = 0;
var Build_This_Hospitals = 0;
var Build_This_Guilds    = 0;
var Build_This_Towers    = 0;
var Build_This_TD        = 0;
var Build_This_WT        = 0;
var Build_This_Libraries = 0;
var Build_This_Schools   = 0;
var Build_This_Stables   = 0;
var Build_This_Dungeons  = 0;
var Build_This_Total     = 0;


var Building_Barren    = 0;
var Building_Homes     = 0;
var Building_Farms     = 0;
var Building_Mills     = 0;
var Building_Banks     = 0;
var Building_TG        = 0;
var Building_Armouries = 0;
var Building_Barracks  = 0;
var Building_Forts     = 0;
var Building_GS        = 0;
var Building_Hospitals = 0;
var Building_Guilds    = 0;
var Building_Towers    = 0;
var Building_TD        = 0;
var Building_WT        = 0;
var Building_Libraries = 0;
var Building_Schools   = 0;
var Building_Stables   = 0;
var Building_Dungeons  = 0;
var Building_Total     = 0;


var Building_Effectiveness = 100;

function Clipboard_Buildings() {

if ( EL == 3 ) {

Export_Line = Export_Line_Decryption(mytext);

Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1);

Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Prov                = ABC_Decryption( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Kingdom             = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Island              = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Total     = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Effectiveness       = Number( Export_Line.slice(0,Export_Line.indexOf("_")) )/100;

Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Barren    = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Homes     = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Farms     = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Mills     = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Banks     = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_TG        = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Armouries = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Barracks  = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Forts     = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_GS        = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Hospitals = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Guilds    = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Towers    = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_TD        = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_WT        = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Libraries = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Schools   = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Stables   = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Available_Dungeons  = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );

Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Barren     = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Homes      = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Farms      = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Mills      = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Banks      = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_TG         = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Armouries  = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Barracks   = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Forts      = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_GS         = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Hospitals  = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Guilds     = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Towers     = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_TD         = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_WT         = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Libraries  = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Schools    = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Stables    = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Building_Progress_Dungeons   = Number( Export_Line.slice(0) );

} else if ( mytext.indexOf("The structures we construct throughout our lands may or may not function at full capacity") != -1 ) {

Building_Prov    = prefService.getCharPref('extensions.Ultima.YourThroneProvinceName' );
Building_Kingdom = prefService.getIntPref('extensions.Ultima.YourThronekingdom'       );
Building_Island  = prefService.getIntPref('extensions.Ultima.YourThroneisland'        );

mytext = mytext.slice(mytext.indexOf("Worth/Acre"));
mytext = mytext.slice(mytext.indexOf(eol)+1);

Building_Total_Money = Number( mytext.slice(0,mytext.indexOf(" ")) );

mytext = mytext.slice(mytext.indexOf(" ")+1); Building_Available_Total = mytext.slice(0,mytext.indexOf(" "));
mytext = mytext.slice(mytext.indexOf(" ")+1); Building_Available_Total = mytext.slice(0,mytext.indexOf(" "));
mytext = mytext.slice(mytext.indexOf(" ")+1); Building_Available_Total = mytext.slice(0,mytext.indexOf(" "));
mytext = mytext.slice(mytext.indexOf(" ")+1); Building_Available_Total = mytext.slice(0,mytext.indexOf(" "));
mytext = mytext.slice(mytext.indexOf(" ")+1); Building_Available_Total = Number( mytext.slice(0,mytext.indexOf(" ")) );

mytext = mytext.slice(mytext.indexOf("Available Workers"));
mytext = mytext.slice(mytext.indexOf(" ")+1);
mytext = mytext.slice(mytext.indexOf(" ")+1);
Building_Available_Workers = mytext.slice(0,mytext.indexOf(eol));
Building_Available_Workers = Number( Building_Available_Workers );

mytext = mytext.slice(mytext.indexOf("Building Efficiency"));
mytext = mytext.slice(mytext.indexOf(" ")+1);
mytext = mytext.slice(mytext.indexOf(" ")+1);
Building_Effectiveness  = mytext.slice(0,mytext.indexOf("%"));
Building_Effectiveness  = Number( Building_Effectiveness );

mytext = mytext.slice(mytext.indexOf("Building Effects"));
mytext = mytext.slice(mytext.indexOf("Barren Land"));

if ( mytext.indexOf( "Barren Land"      ) != -1 ) { mytext = mytext.slice( "Barren Land"      ); Building_Available_Barren    = CB_Find( mytext, "Barren Land"      , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Homes"            ) != -1 ) { mytext = mytext.slice( "Homes"            ); Building_Available_Homes     = CB_Find( mytext, "Homes"            , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Farms"            ) != -1 ) { mytext = mytext.slice( "Farms"            ); Building_Available_Farms     = CB_Find( mytext, "Farms"            , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Mills"            ) != -1 ) { mytext = mytext.slice( "Mills"            ); Building_Available_Mills     = CB_Find( mytext, "Mills"            , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Banks"            ) != -1 ) { mytext = mytext.slice( "Banks"            ); Building_Available_Banks     = CB_Find( mytext, "Banks"            , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Training Grounds" ) != -1 ) { mytext = mytext.slice( "Training Grounds" ); Building_Available_TG        = CB_Find( mytext, "Training Grounds" , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Armouries"        ) != -1 ) { mytext = mytext.slice( "Armouries"        ); Building_Available_Armouries = CB_Find( mytext, "Armouries"        , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Military Barracks") != -1 ) { mytext = mytext.slice( "Military Barracks"); Building_Available_Barracks  = CB_Find( mytext, "Military Barracks", " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Forts"            ) != -1 ) { mytext = mytext.slice( "Forts"            ); Building_Available_Forts     = CB_Find( mytext, "Forts"            , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Guard Stations"   ) != -1 ) { mytext = mytext.slice( "Guard Stations"   ); Building_Available_GS        = CB_Find( mytext, "Guard Stations"   , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Hospitals"        ) != -1 ) { mytext = mytext.slice( "Hospitals"        ); Building_Available_Hospitals = CB_Find( mytext, "Hospitals"        , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Guilds"           ) != -1 ) { mytext = mytext.slice( "Guilds"           ); Building_Available_Guilds    = CB_Find( mytext, "Guilds"           , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Towers"           ) != -1 ) { mytext = mytext.slice( "Towers"           ); Building_Available_Towers    = CB_Find( mytext, "Towers"           , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Thieves' Dens"    ) != -1 ) { mytext = mytext.slice( "Thieves' Dens"    ); Building_Available_TD        = CB_Find( mytext, "Thieves' Dens"    , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Watch Towers"     ) != -1 ) { mytext = mytext.slice( "Watch Towers"     ); Building_Available_WT        = CB_Find( mytext, "Watch Towers"     , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Libraries"        ) != -1 ) { mytext = mytext.slice( "Libraries"        ); Building_Available_Libraries = CB_Find( mytext, "Libraries"        , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Schools"          ) != -1 ) { mytext = mytext.slice( "Schools"          ); Building_Available_Schools   = CB_Find( mytext, "Schools"          , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Stables"          ) != -1 ) { mytext = mytext.slice( "Stables"          ); Building_Available_Stables   = CB_Find( mytext, "Stables"          , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Dungeons"         ) != -1 ) { mytext = mytext.slice( "Dungeons"         ); Building_Available_Dungeons  = CB_Find( mytext, "Dungeons"         , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1); }

Building_Available_Barren    = Number( Building_Available_Barren    );
Building_Available_Homes     = Number( Building_Available_Homes     );
Building_Available_Farms     = Number( Building_Available_Farms     );
Building_Available_Mills     = Number( Building_Available_Mills     );
Building_Available_Banks     = Number( Building_Available_Banks     );
Building_Available_TG        = Number( Building_Available_TG        );
Building_Available_Armouries = Number( Building_Available_Armouries );
Building_Available_Barracks  = Number( Building_Available_Barracks  );
Building_Available_Forts     = Number( Building_Available_Forts     );
Building_Available_GS        = Number( Building_Available_GS        );
Building_Available_Hospitals = Number( Building_Available_Hospitals );
Building_Available_Guilds    = Number( Building_Available_Guilds    );
Building_Available_Towers    = Number( Building_Available_Towers    );
Building_Available_TD        = Number( Building_Available_TD        );
Building_Available_WT        = Number( Building_Available_WT        );
Building_Available_Libraries = Number( Building_Available_Libraries );
Building_Available_Schools   = Number( Building_Available_Schools   );
Building_Available_Stables   = Number( Building_Available_Stables   );
Building_Available_Dungeons  = Number( Building_Available_Dungeons  );


Building_Percentage_Barren    = 0;
Building_Percentage_Homes     = 0;
Building_Percentage_Farms     = 0;
Building_Percentage_Mills     = 0;
Building_Percentage_Banks     = 0;
Building_Percentage_TG        = 0;
Building_Percentage_Armouries = 0;
Building_Percentage_Barracks  = 0;
Building_Percentage_Forts     = 0;
Building_Percentage_GS        = 0;
Building_Percentage_Hospitals = 0;
Building_Percentage_Guilds    = 0;
Building_Percentage_Towers    = 0;
Building_Percentage_TD        = 0;
Building_Percentage_WT        = 0;
Building_Percentage_Libraries = 0;
Building_Percentage_Schools   = 0;
Building_Percentage_Stables   = 0;
Building_Percentage_Dungeons  = 0;

mytext = mytext.slice(mytext.indexOf(" ")+1);

Building_Percentage_Barren    = Math.round( Building_Available_Barren    / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Homes     = Math.round( Building_Available_Homes     / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Farms     = Math.round( Building_Available_Farms     / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Mills     = Math.round( Building_Available_Mills     / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Banks     = Math.round( Building_Available_Banks     / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_TG        = Math.round( Building_Available_TG        / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Armouries = Math.round( Building_Available_Armouries / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Barracks  = Math.round( Building_Available_Barracks  / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Forts     = Math.round( Building_Available_Forts     / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_GS        = Math.round( Building_Available_GS        / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Hospitals = Math.round( Building_Available_Hospitals / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Guilds    = Math.round( Building_Available_Guilds    / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Towers    = Math.round( Building_Available_Towers    / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_TD        = Math.round( Building_Available_TD        / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_WT        = Math.round( Building_Available_WT        / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Libraries = Math.round( Building_Available_Libraries / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Schools   = Math.round( Building_Available_Schools   / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Stables   = Math.round( Building_Available_Stables   / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Dungeons  = Math.round( Building_Available_Dungeons  / Building_Available_Total * 1000 ) /10 ;

var temp=0;

Building_Progress_Barren    = 0;
Building_Progress_Homes     = 0;
Building_Progress_Farms     = 0;
Building_Progress_Mills     = 0;
Building_Progress_Banks     = 0;
Building_Progress_TG        = 0;
Building_Progress_Armouries = 0;
Building_Progress_Barracks  = 0;
Building_Progress_Forts     = 0;
Building_Progress_GS        = 0;
Building_Progress_Hospitals = 0;
Building_Progress_Guilds    = 0;
Building_Progress_Towers    = 0;
Building_Progress_TD        = 0;
Building_Progress_WT        = 0;
Building_Progress_Libraries = 0;
Building_Progress_Schools   = 0;
Building_Progress_Stables   = 0;
Building_Progress_Dungeons  = 0;

mytext = mytext.slice(mytext.indexOf("Barren Land"));

if ( mytext.indexOf( "Barren Land"      ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Barren Land"      )+12,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Barren    += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Homes"            ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Homes"            )+ 6,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Homes     += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Farms"            ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Farms"            )+ 6,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Farms     += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Mills"            ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Mills"            )+ 6,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Mills     += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Banks"            ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Banks"            )+ 6,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Banks     += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Training Grounds" ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Training Grounds" )+17,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_TG        += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Armouries"        ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Armouries"        )+10,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Armouries += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Military Barracks") != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Military Barracks")+18,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Barracks  += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Forts"            ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Forts"            )+ 6,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Forts     += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Guard Stations"   ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Guard Stations"   )+15,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_GS        += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Hospitals"        ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Hospitals"        )+10,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Hospitals += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Guilds"           ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Guilds"           )+ 7,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Guilds    += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Towers"           ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Towers"           )+ 7,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Towers    += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Thieves' Dens"    ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Thieves' Dens"    )+14,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_TD        += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Watch Towers"     ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Watch Towers"     )+13,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_WT        += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Libraries"        ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Libraries"        )+10,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Libraries += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Schools"          ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Schools"          )+ 8,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Schools   += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Stables"          ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Stables"          )+ 8,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Stables   += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }
if ( mytext.indexOf( "Dungeons"         ) != -1 ) { temp2 = mytext.slice(mytext.indexOf( "Dungeons"         )+ 9,mytext.indexOf(eol)); for (temp=1; temp<=24; temp++){ Building_Progress_Dungeons  += Number( temp2.slice(0,temp2.indexOf(" ")) ); temp2 = temp2.slice(temp2.indexOf(" ")+1); } mytext = mytext.slice(mytext.indexOf(eol)+1); }



prefService.setBoolPref('extensions.Ultima.Building_Bonuses_Box'         , true );
prefService.setIntPref('extensions.Ultima.Building_Race'                 , prefService.getIntPref('extensions.Ultima.YourThroneRace' ) );
prefService.setIntPref('extensions.Ultima.Building_Personality'          , prefService.getIntPref('extensions.Ultima.YourThronePersonality' ) );
prefService.setIntPref('extensions.Ultima.Building_Available_Workers'    , Building_Available_Workers );
prefService.setIntPref('extensions.Ultima.Building_Total_Money'          , Building_Total_Money );
prefService.setIntPref('extensions.Ultima.Building_Effectiveness'        , Building_Effectiveness * 100 );


prefService.setIntPref('extensions.Ultima.Building_Available_Barren'     , Building_Available_Barren    );
prefService.setIntPref('extensions.Ultima.Building_Available_Homes'      , Building_Available_Homes     );
prefService.setIntPref('extensions.Ultima.Building_Available_Farms'      , Building_Available_Farms     );
prefService.setIntPref('extensions.Ultima.Building_Available_Mills'      , Building_Available_Mills     );
prefService.setIntPref('extensions.Ultima.Building_Available_Banks'      , Building_Available_Banks     );
prefService.setIntPref('extensions.Ultima.Building_Available_TG'         , Building_Available_TG        );
prefService.setIntPref('extensions.Ultima.Building_Available_Armouries'  , Building_Available_Armouries );
prefService.setIntPref('extensions.Ultima.Building_Available_Barracks'   , Building_Available_Barracks  );
prefService.setIntPref('extensions.Ultima.Building_Available_Forts'      , Building_Available_Forts     );
prefService.setIntPref('extensions.Ultima.Building_Available_GS'         , Building_Available_GS        );
prefService.setIntPref('extensions.Ultima.Building_Available_Hospitals'  , Building_Available_Hospitals );
prefService.setIntPref('extensions.Ultima.Building_Available_Guilds'     , Building_Available_Guilds    );
prefService.setIntPref('extensions.Ultima.Building_Available_Towers'     , Building_Available_Towers    );
prefService.setIntPref('extensions.Ultima.Building_Available_TD'         , Building_Available_TD        );
prefService.setIntPref('extensions.Ultima.Building_Available_WT'         , Building_Available_WT        );
prefService.setIntPref('extensions.Ultima.Building_Available_Libraries'  , Building_Available_Libraries );
prefService.setIntPref('extensions.Ultima.Building_Available_Schools'    , Building_Available_Schools   );
prefService.setIntPref('extensions.Ultima.Building_Available_Stables'    , Building_Available_Stables   );
prefService.setIntPref('extensions.Ultima.Building_Available_Dungeons'   , Building_Available_Dungeons  );


prefService.setIntPref('extensions.Ultima.Building_Progress_Barren'     , Building_Progress_Barren    );
prefService.setIntPref('extensions.Ultima.Building_Progress_Homes'      , Building_Progress_Homes     );
prefService.setIntPref('extensions.Ultima.Building_Progress_Farms'      , Building_Progress_Farms     );
prefService.setIntPref('extensions.Ultima.Building_Progress_Mills'      , Building_Progress_Mills     );
prefService.setIntPref('extensions.Ultima.Building_Progress_Banks'      , Building_Progress_Banks     );
prefService.setIntPref('extensions.Ultima.Building_Progress_TG'         , Building_Progress_TG        );
prefService.setIntPref('extensions.Ultima.Building_Progress_Armouries'  , Building_Progress_Armouries );
prefService.setIntPref('extensions.Ultima.Building_Progress_Barracks'   , Building_Progress_Barracks  );
prefService.setIntPref('extensions.Ultima.Building_Progress_Forts'      , Building_Progress_Forts     );
prefService.setIntPref('extensions.Ultima.Building_Progress_GS'         , Building_Progress_GS        );
prefService.setIntPref('extensions.Ultima.Building_Progress_Hospitals'  , Building_Progress_Hospitals );
prefService.setIntPref('extensions.Ultima.Building_Progress_Guilds'     , Building_Progress_Guilds    );
prefService.setIntPref('extensions.Ultima.Building_Progress_Towers'     , Building_Progress_Towers    );
prefService.setIntPref('extensions.Ultima.Building_Progress_TD'         , Building_Progress_TD        );
prefService.setIntPref('extensions.Ultima.Building_Progress_WT'         , Building_Progress_WT        );
prefService.setIntPref('extensions.Ultima.Building_Progress_Libraries'  , Building_Progress_Libraries );
prefService.setIntPref('extensions.Ultima.Building_Progress_Schools'    , Building_Progress_Schools   );
prefService.setIntPref('extensions.Ultima.Building_Progress_Stables'    , Building_Progress_Stables   );
prefService.setIntPref('extensions.Ultima.Building_Progress_Dungeons'   , Building_Progress_Dungeons  );

Building_Progress_Total = Building_Progress_Homes + Building_Progress_Farms + Building_Progress_Mills + Building_Progress_Banks + Building_Progress_TG + Building_Progress_Armouries + Building_Progress_Barracks + Building_Progress_Forts + Building_Progress_GS + Building_Progress_Hospitals + Building_Progress_Guilds + Building_Progress_Towers + Building_Progress_TD + Building_Progress_WT + Building_Progress_Libraries + Building_Progress_Schools + Building_Progress_Stables + Building_Progress_Dungeons;

Building_Available_Total = Building_Progress_Total + Building_Available_Barren + Building_Available_Homes + Building_Available_Farms + Building_Available_Mills + Building_Available_Banks + Building_Available_TG + Building_Available_Armouries + Building_Available_Barracks + Building_Available_Forts + Building_Available_GS + Building_Available_Hospitals + Building_Available_Guilds + Building_Available_Towers + Building_Available_TD + Building_Available_WT + Building_Available_Libraries + Building_Available_Schools + Building_Available_Stables + Building_Available_Dungeons ;




} else if ( mytext.indexOf("Our thieves scour the lands") != -1 ) {

mytext = mytext.slice(mytext.indexOf("Our thieves scour the lands of")+31);
temp = mytext.slice(0,mytext.indexOf(")")+1);

Building_Prov    = temp.slice(0,temp.indexOf("("));
Building_Kingdom = temp.slice(temp.indexOf("(")+1,temp.indexOf(":"));
Building_Island  = temp.slice(temp.indexOf(":")+1,temp.indexOf(")"));

mytext = mytext.slice(mytext.indexOf("Available Workers"));
mytext = mytext.slice(mytext.indexOf(" ")+1);
mytext = mytext.slice(mytext.indexOf(" ")+1);
Building_Available_Workers = mytext.slice(0,mytext.indexOf(" "));
Building_Available_Workers = Number( Building_Available_Workers );

mytext = mytext.slice(mytext.indexOf("Building Efficiency"));
mytext = mytext.slice(mytext.indexOf(" ")+1);
mytext = mytext.slice(mytext.indexOf(" ")+1);
Building_Effectiveness  = mytext.slice(0,mytext.indexOf("%"));
Building_Effectiveness  = Number( Building_Effectiveness );

mytext = mytext.slice( "Barren Land"      ); Building_Available_Barren    = CB_Find( mytext, "Barren Land"      , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Homes"            ); Building_Available_Homes     = CB_Find( mytext, "Homes"            , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Farms"            ); Building_Available_Farms     = CB_Find( mytext, "Farms"            , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Mills"            ); Building_Available_Mills     = CB_Find( mytext, "Mills"            , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Banks"            ); Building_Available_Banks     = CB_Find( mytext, "Banks"            , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Training Grounds" ); Building_Available_TG        = CB_Find( mytext, "Training Grounds" , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Armouries"        ); Building_Available_Armouries = CB_Find( mytext, "Armouries"        , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Military Barracks"); Building_Available_Barracks  = CB_Find( mytext, "Military Barracks", " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Forts"            ); Building_Available_Forts     = CB_Find( mytext, "Forts"            , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Guard Stations"   ); Building_Available_GS        = CB_Find( mytext, "Guard Stations"   , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Hospitals"        ); Building_Available_Hospitals = CB_Find( mytext, "Hospitals"        , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Guilds"           ); Building_Available_Guilds    = CB_Find( mytext, "Guilds"           , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Towers"           ); Building_Available_Towers    = CB_Find( mytext, "Towers"           , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Thieves' Dens"    ); Building_Available_TD        = CB_Find( mytext, "Thieves' Dens"    , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Watch Towers"     ); Building_Available_WT        = CB_Find( mytext, "Watch Towers"     , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Libraries"        ); Building_Available_Libraries = CB_Find( mytext, "Libraries"        , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Schools"          ); Building_Available_Schools   = CB_Find( mytext, "Schools"          , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Stables"          ); Building_Available_Stables   = CB_Find( mytext, "Stables"          , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice( "Dungeons"         ); Building_Available_Dungeons  = CB_Find( mytext, "Dungeons"         , " " ); mytext = mytext.slice(mytext.indexOf(eol)+1);

Building_Available_Total = Building_Available_Barren + Building_Available_Homes + Building_Available_Farms + Building_Available_Mills + Building_Available_Banks + Building_Available_TG + Building_Available_Armouries + Building_Available_Barracks + Building_Available_Forts + Building_Available_GS + Building_Available_Hospitals + Building_Available_Guilds + Building_Available_Towers + Building_Available_TD + Building_Available_WT + Building_Available_Libraries + Building_Available_Schools + Building_Available_Stables + Building_Available_Dungeons;

Building_Progress_Barren    = 0;
Building_Progress_Homes     = 0;
Building_Progress_Farms     = 0;
Building_Progress_Mills     = 0;
Building_Progress_Banks     = 0;
Building_Progress_TG        = 0;
Building_Progress_Armouries = 0;
Building_Progress_Barracks  = 0;
Building_Progress_Forts     = 0;
Building_Progress_GS        = 0;
Building_Progress_Hospitals = 0;
Building_Progress_Guilds    = 0;
Building_Progress_Towers    = 0;
Building_Progress_TD        = 0;
Building_Progress_WT        = 0;
Building_Progress_Libraries = 0;
Building_Progress_Schools   = 0;
Building_Progress_Stables   = 0;
Building_Progress_Dungeons  = 0;

Building_Progress_Total     = 0;

if ( Building_Available_Total > 0 ) {

Building_Percentage_Barren    = Math.round( Building_Available_Barren    / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Homes     = Math.round( Building_Available_Homes     / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Farms     = Math.round( Building_Available_Farms     / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Mills     = Math.round( Building_Available_Mills     / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Banks     = Math.round( Building_Available_Banks     / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_TG        = Math.round( Building_Available_TG        / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Armouries = Math.round( Building_Available_Armouries / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Barracks  = Math.round( Building_Available_Barracks  / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Forts     = Math.round( Building_Available_Forts     / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_GS        = Math.round( Building_Available_GS        / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Hospitals = Math.round( Building_Available_Hospitals / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Guilds    = Math.round( Building_Available_Guilds    / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Towers    = Math.round( Building_Available_Towers    / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_TD        = Math.round( Building_Available_TD        / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_WT        = Math.round( Building_Available_WT        / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Libraries = Math.round( Building_Available_Libraries / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Schools   = Math.round( Building_Available_Schools   / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Stables   = Math.round( Building_Available_Stables   / Building_Available_Total * 1000 ) /10 ;
Building_Percentage_Dungeons  = Math.round( Building_Available_Dungeons  / Building_Available_Total * 1000 ) /10 ;

}

if ( Building_Available_Total == 0 ) {

Building_Percentage_Barren    = 0;
Building_Percentage_Homes     = 0;
Building_Percentage_Farms     = 0;
Building_Percentage_Mills     = 0;
Building_Percentage_Banks     = 0;
Building_Percentage_TG        = 0;
Building_Percentage_Armouries = 0;
Building_Percentage_Barracks  = 0;
Building_Percentage_Forts     = 0;
Building_Percentage_GS        = 0;
Building_Percentage_Hospitals = 0;
Building_Percentage_Guilds    = 0;
Building_Percentage_Towers    = 0;
Building_Percentage_TD        = 0;
Building_Percentage_WT        = 0;
Building_Percentage_Libraries = 0;
Building_Percentage_Schools   = 0;
Building_Percentage_Stables   = 0;
Building_Percentage_Dungeons  = 0;
Building_Percentage_Total     = 0;

}

}




Export_Line = "_984"
Export_Line += "_" + ABC_Encryption(Building_Prov)
Export_Line += "_" + Building_Kingdom
Export_Line += "_" + Building_Island
Export_Line += "_" + Building_Available_Total
Export_Line += "_" + Math.round(Building_Effectiveness*100)

Export_Line += "_" + Building_Available_Barren
Export_Line += "_" + Building_Available_Homes
Export_Line += "_" + Building_Available_Farms
Export_Line += "_" + Building_Available_Mills
Export_Line += "_" + Building_Available_Banks
Export_Line += "_" + Building_Available_TG
Export_Line += "_" + Building_Available_Armouries
Export_Line += "_" + Building_Available_Barracks
Export_Line += "_" + Building_Available_Forts
Export_Line += "_" + Building_Available_GS
Export_Line += "_" + Building_Available_Hospitals
Export_Line += "_" + Building_Available_Guilds
Export_Line += "_" + Building_Available_Towers
Export_Line += "_" + Building_Available_TD
Export_Line += "_" + Building_Available_WT
Export_Line += "_" + Building_Available_Libraries
Export_Line += "_" + Building_Available_Schools
Export_Line += "_" + Building_Available_Stables
Export_Line += "_" + Building_Available_Dungeons

Export_Line += "_" + Building_Progress_Barren
Export_Line += "_" + Building_Progress_Homes
Export_Line += "_" + Building_Progress_Farms
Export_Line += "_" + Building_Progress_Mills
Export_Line += "_" + Building_Progress_Banks
Export_Line += "_" + Building_Progress_TG
Export_Line += "_" + Building_Progress_Armouries
Export_Line += "_" + Building_Progress_Barracks
Export_Line += "_" + Building_Progress_Forts
Export_Line += "_" + Building_Progress_GS
Export_Line += "_" + Building_Progress_Hospitals
Export_Line += "_" + Building_Progress_Guilds
Export_Line += "_" + Building_Progress_Towers
Export_Line += "_" + Building_Progress_TD
Export_Line += "_" + Building_Progress_WT
Export_Line += "_" + Building_Progress_Libraries
Export_Line += "_" + Building_Progress_Schools
Export_Line += "_" + Building_Progress_Stables
Export_Line += "_" + Building_Progress_Dungeons



textonly =""+c0+"Buildings Report of "+Building_Prov+" ("+Building_Kingdom+":"+Building_Island+")"+cc+Copyrights;
textonly += "<br />"+c1+"Building Efficiency: "+cc+c2+ Building_Effectiveness +"%"+cc;
textonly += "<br />"+c1+"Kingdom Stance: "+cc+c2+"Normal"+cc;
textonly += "<br />";

var xx=0;

if (( Building_Available_Homes     != 0 )||( Building_Progress_Homes     != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Homes: "                   +cc; textonly += c2+ Building_Available_Homes     +cc+c1+" ("+cc+c2+ Building_Percentage_Homes     +"%"+cc+c1+")" ; if ( Building_Progress_Homes     != 0 ) textonly += " + " +cc+c2+ Building_Progress_Homes     +cc+c1+ " in progress (+" + Math.round( Building_Progress_Homes     / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Farms     != 0 )||( Building_Progress_Farms     != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Farms: "                   +cc; textonly += c2+ Building_Available_Farms     +cc+c1+" ("+cc+c2+ Building_Percentage_Farms     +"%"+cc+c1+")" ; if ( Building_Progress_Farms     != 0 ) textonly += " + " +cc+c2+ Building_Progress_Farms     +cc+c1+ " in progress (+" + Math.round( Building_Progress_Farms     / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Mills     != 0 )||( Building_Progress_Mills     != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Mills: "                   +cc; textonly += c2+ Building_Available_Mills     +cc+c1+" ("+cc+c2+ Building_Percentage_Mills     +"%"+cc+c1+")" ; if ( Building_Progress_Mills     != 0 ) textonly += " + " +cc+c2+ Building_Progress_Mills     +cc+c1+ " in progress (+" + Math.round( Building_Progress_Mills     / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Banks     != 0 )||( Building_Progress_Banks     != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Banks: "                   +cc; textonly += c2+ Building_Available_Banks     +cc+c1+" ("+cc+c2+ Building_Percentage_Banks     +"%"+cc+c1+")" ; if ( Building_Progress_Banks     != 0 ) textonly += " + " +cc+c2+ Building_Progress_Banks     +cc+c1+ " in progress (+" + Math.round( Building_Progress_Banks     / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_TG        != 0 )||( Building_Progress_TG        != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Training Grounds: "        +cc; textonly += c2+ Building_Available_TG        +cc+c1+" ("+cc+c2+ Building_Percentage_TG        +"%"+cc+c1+")" ; if ( Building_Progress_TG        != 0 ) textonly += " + " +cc+c2+ Building_Progress_TG        +cc+c1+ " in progress (+" + Math.round( Building_Progress_TG        / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Armouries != 0 )||( Building_Progress_Armouries != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Armouries: "               +cc; textonly += c2+ Building_Available_Armouries +cc+c1+" ("+cc+c2+ Building_Percentage_Armouries +"%"+cc+c1+")" ; if ( Building_Progress_Armouries != 0 ) textonly += " + " +cc+c2+ Building_Progress_Armouries +cc+c1+ " in progress (+" + Math.round( Building_Progress_Armouries / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Barracks  != 0 )||( Building_Progress_Barracks  != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Military Barracks: "       +cc; textonly += c2+ Building_Available_Barracks  +cc+c1+" ("+cc+c2+ Building_Percentage_Barracks  +"%"+cc+c1+")" ; if ( Building_Progress_Barracks  != 0 ) textonly += " + " +cc+c2+ Building_Progress_Barracks  +cc+c1+ " in progress (+" + Math.round( Building_Progress_Barracks  / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Forts     != 0 )||( Building_Progress_Forts     != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Forts: "                   +cc; textonly += c2+ Building_Available_Forts     +cc+c1+" ("+cc+c2+ Building_Percentage_Forts     +"%"+cc+c1+")" ; if ( Building_Progress_Forts     != 0 ) textonly += " + " +cc+c2+ Building_Progress_Forts     +cc+c1+ " in progress (+" + Math.round( Building_Progress_Forts     / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_GS        != 0 )||( Building_Progress_GS        != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Guard Stations: "          +cc; textonly += c2+ Building_Available_GS        +cc+c1+" ("+cc+c2+ Building_Percentage_GS        +"%"+cc+c1+")" ; if ( Building_Progress_GS        != 0 ) textonly += " + " +cc+c2+ Building_Progress_GS        +cc+c1+ " in progress (+" + Math.round( Building_Progress_GS        / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Hospitals != 0 )||( Building_Progress_Hospitals != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Hospitals: "               +cc; textonly += c2+ Building_Available_Hospitals +cc+c1+" ("+cc+c2+ Building_Percentage_Hospitals +"%"+cc+c1+")" ; if ( Building_Progress_Hospitals != 0 ) textonly += " + " +cc+c2+ Building_Progress_Hospitals +cc+c1+ " in progress (+" + Math.round( Building_Progress_Hospitals / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Guilds    != 0 )||( Building_Progress_Guilds    != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Guilds: "                  +cc; textonly += c2+ Building_Available_Guilds    +cc+c1+" ("+cc+c2+ Building_Percentage_Guilds    +"%"+cc+c1+")" ; if ( Building_Progress_Guilds    != 0 ) textonly += " + " +cc+c2+ Building_Progress_Guilds    +cc+c1+ " in progress (+" + Math.round( Building_Progress_Guilds    / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Towers    != 0 )||( Building_Progress_Towers    != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Towers: "                  +cc; textonly += c2+ Building_Available_Towers    +cc+c1+" ("+cc+c2+ Building_Percentage_Towers    +"%"+cc+c1+")" ; if ( Building_Progress_Towers    != 0 ) textonly += " + " +cc+c2+ Building_Progress_Towers    +cc+c1+ " in progress (+" + Math.round( Building_Progress_Towers    / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_TD        != 0 )||( Building_Progress_TD        != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Thieves' Dens: "           +cc; textonly += c2+ Building_Available_TD        +cc+c1+" ("+cc+c2+ Building_Percentage_TD        +"%"+cc+c1+")" ; if ( Building_Progress_TD        != 0 ) textonly += " + " +cc+c2+ Building_Progress_TD        +cc+c1+ " in progress (+" + Math.round( Building_Progress_TD        / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_WT        != 0 )||( Building_Progress_WT        != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Watch Towers: "            +cc; textonly += c2+ Building_Available_WT        +cc+c1+" ("+cc+c2+ Building_Percentage_WT        +"%"+cc+c1+")" ; if ( Building_Progress_WT        != 0 ) textonly += " + " +cc+c2+ Building_Progress_WT        +cc+c1+ " in progress (+" + Math.round( Building_Progress_WT        / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Libraries != 0 )||( Building_Progress_Libraries != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Libraries: "               +cc; textonly += c2+ Building_Available_Libraries +cc+c1+" ("+cc+c2+ Building_Percentage_Libraries +"%"+cc+c1+")" ; if ( Building_Progress_Libraries != 0 ) textonly += " + " +cc+c2+ Building_Progress_Libraries +cc+c1+ " in progress (+" + Math.round( Building_Progress_Libraries / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Schools   != 0 )||( Building_Progress_Schools   != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Schools: "                 +cc; textonly += c2+ Building_Available_Schools   +cc+c1+" ("+cc+c2+ Building_Percentage_Schools   +"%"+cc+c1+")" ; if ( Building_Progress_Schools   != 0 ) textonly += " + " +cc+c2+ Building_Progress_Schools   +cc+c1+ " in progress (+" + Math.round( Building_Progress_Schools   / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Stables   != 0 )||( Building_Progress_Stables   != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Stables: "                 +cc; textonly += c2+ Building_Available_Stables   +cc+c1+" ("+cc+c2+ Building_Percentage_Stables   +"%"+cc+c1+")" ; if ( Building_Progress_Stables   != 0 ) textonly += " + " +cc+c2+ Building_Progress_Stables   +cc+c1+ " in progress (+" + Math.round( Building_Progress_Stables   / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }
if (( Building_Available_Dungeons  != 0 )||( Building_Progress_Dungeons  != 0 )) { xx+=1; textonly += "<br />"+c1+xx+". Dungeons: "                +cc; textonly += c2+ Building_Available_Dungeons  +cc+c1+" ("+cc+c2+ Building_Percentage_Dungeons  +"%"+cc+c1+")" ; if ( Building_Progress_Dungeons  != 0 ) textonly += " + " +cc+c2+ Building_Progress_Dungeons  +cc+c1+ " in progress (+" + Math.round( Building_Progress_Dungeons  / Building_Available_Total * 1000 ) /10 + "%)" +cc ; }

textonly += "<br />";
textonly += "<br />"+c1+"Total Land: "      +cc+c2+ Building_Available_Total     +cc+c1+" Acres"+cc;

formated_text = textonly;

textonly = textonly.replace(/<font color='#aa8822'>/g, "");
textonly = textonly.replace(/<font>/g, "");
textonly = textonly.replace(/<font color='#888888'>/g, "");
textonly = textonly.replace(/<font color='#ff0000'>/g, "");
textonly = textonly.replace(/<\/font>/g, "");
textonly = textonly.replace(/<br \/>/g, String.fromCharCode(13,10));

formated_copy = textonly;

formated_copy += String.fromCharCode(13,10) + "** Export Line [ver 1] -- Survey [ver 1]: **" + String.fromCharCode(13,10) + Export_Line_Encryption(Export_Line);

}
